package mt.demo.service.comm;

import mt.demo.service.security.WatUserDetails;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

/**
 * Created by 田西泽 on 2015-8-14.
 */
@Component
public class WatControllerDefaultData {
    public WatUserDetails getCurrentYomsUserDetails() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        if (authentication != null) {
            Object obj = authentication.getPrincipal();
            if (obj.getClass() == WatUserDetails.class) {
                WatUserDetails userDetails = (WatUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
                return userDetails;
            }
        }
        return null;
    }
}
